﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace Wimm.Common.Converters
{
    public class LongToDateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null)
                return null;

            if (parameter == null)
                return null;

            var date = new DateTime((long)value);

            if (date.Date == DateTime.Now.Date)
            {
                return "FilterToday".GetStringFromResource(language);
            }
            else if (date.Date == DateTime.Now.AddDays(-1).Date)
            {
                return "FilterYesterday".GetStringFromResource(language);
            }
            else
            {
                return date.ToString(parameter.ToString());
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
